import { AddTypeParam, EditTypeParam, GetTypeParam, TypeListType } from "@Tea/model"
import { TypeRepository } from "../repo/TypeManageRepository"

export class TypeManageCxt {
  private static inst: TypeManageCxt
  private typeRepo: TypeRepository = TypeRepository.getInstance()

  public static getInstance() {
    if (!TypeManageCxt.inst) {
      TypeManageCxt.inst = new TypeManageCxt()
    }

    return TypeManageCxt.inst
  }

  // 获取类别列表的操作
  async getTypeList(params: GetTypeParam) {
    return (await this.typeRepo.getTypeList(params))[0]
  }

  // 添加类别
  async addType(params: AddTypeParam) {
    return this.typeRepo.addType(params)
  }

  // 编辑
  async editType(params: EditTypeParam) {
    return this.typeRepo.editType(params)
  } 


  async delType(typeId: TypeListType['typeId']) {
    return this.typeRepo.delType(typeId)
  }
}